home *** CD-ROM | disk | FTP | other *** search
/ AOL File Library: 2,801 to 2,900 / aol-file-protocol-4400-2801-to-2900.zip / AOLDLs / C++ Files Library / LAboutBox (PP) / LAboutBox.sit / LAboutBox / LAboutBox.cp < prev    next >
Text File  |  1995-08-28  |  4KB  |  152 lines

  1. // ===========================================================================
  2. //    LAboutBox.cp                    ⌐ 1995, âric Forget. All rights reserved.
  3. // ===========================================================================
  4. //    
  5. //    ************************************************************************
  6. //    *                                                                      *
  7. //    *    Before using this code you should read the "License Agreement"     *
  8. //    *    document and agree with it.                                        *
  9. //    *                                                                      *
  10. //    ************************************************************************
  11. //
  12. //    LAboutBox is a wrapper class to make life easier when implementing an
  13. //    about box.
  14. //
  15. // ---------------------------------------------------------------------------
  16. //
  17. //    Instruction Notes:
  18. //    -----------------
  19. //
  20. //    1) Write a PPob resource with Constructor (or whatever you want!);
  21. //
  22. //    2) Write a RidL resource (even an empty one!) with the same ID as your PPob;
  23. //
  24. //    3) Call LAboutBox::DoAboutBox(), a static method.
  25. //
  26. // ---------------------------------------------------------------------------
  27.  
  28. #include    "LAboutBox.h"
  29.  
  30. #include    <UModalDialogs.h>
  31.  
  32.  
  33.  
  34. // ---------------------------------------------------------------------------
  35. //        Ñ DoAboutBox
  36. // ---------------------------------------------------------------------------
  37.  
  38. void
  39. LAboutBox::DoAboutBox(
  40.     ResIDT    inResID)
  41. {
  42.     StDialogHandler        theHandler(inResID, LCommander::GetTopCommander());
  43.     LDialogBox            *theDialog = (LDialogBox *)theHandler.GetDialog();
  44.     MessageT            hitMessage = msg_Nothing;
  45.     
  46.     
  47.     theDialog->Show();
  48.     
  49.     while (hitMessage == msg_Nothing) {        // Let DialogHandler process events
  50.         
  51.         hitMessage = theHandler.DoDialog();
  52.     }
  53. }
  54.  
  55.  
  56. // ---------------------------------------------------------------------------
  57. //        Ñ CreateAboutBoxStream [static]
  58. // ---------------------------------------------------------------------------
  59. //    Return a new AboutBox object initialized using data from a Stream
  60.  
  61. LAboutBox*
  62. LAboutBox::CreateAboutBoxStream(
  63.     LStream    *inStream)
  64. {
  65.     return (new LAboutBox(inStream));
  66. }
  67.  
  68.  
  69. // ---------------------------------------------------------------------------
  70. //        Ñ LAboutBox
  71. // ---------------------------------------------------------------------------
  72. //    Default Constructor
  73.  
  74. LAboutBox::LAboutBox()
  75. {
  76. }
  77.  
  78.  
  79. // ---------------------------------------------------------------------------
  80. //        Ñ LAboutBox(SWindowInfo&)
  81. // ---------------------------------------------------------------------------
  82. //    Construct AboutBox from the data in a struct
  83.  
  84. LAboutBox::LAboutBox(
  85.     SWindowInfo    &inWindowInfo)
  86.         : LDialogBox(inWindowInfo)
  87. {
  88. }
  89.  
  90.  
  91. // ---------------------------------------------------------------------------
  92. //        Ñ LAboutBox(ResIDT, Uint32, LCommander*)
  93. // ---------------------------------------------------------------------------
  94. //    Construct a AboutBox from a WIND Resource with the specified attributes
  95. //    and SuperCommander
  96. //
  97. //    Side Effect: Created window becomes the current port
  98.  
  99. LAboutBox::LAboutBox(
  100.     ResIDT        inWINDid,
  101.     Uint32        inAttributes,
  102.     LCommander    *inSuper)
  103.         : LDialogBox(inWINDid, inAttributes, inSuper)
  104. {
  105. }
  106.  
  107.  
  108. // ---------------------------------------------------------------------------
  109. //        Ñ LAboutBox(LStream*)
  110. // ---------------------------------------------------------------------------
  111. //    Construct a AboutBox from the data in a Stream
  112.  
  113. LAboutBox::LAboutBox(
  114.     LStream    *inStream)
  115.         : LDialogBox(inStream)
  116. {
  117. }
  118.  
  119.  
  120. // ---------------------------------------------------------------------------
  121. //        Ñ HandleClick
  122. // ---------------------------------------------------------------------------
  123. //    Respond to a click on a Window
  124. //
  125. //    The inPart parameter is the part code returned by the Toolbox FindWindow
  126. //    routine.
  127.  
  128. void
  129. LAboutBox::HandleClick(
  130.     const EventRecord    &/*inMacEvent*/,
  131.     Int16                /*inPart*/)
  132. {
  133.     mSuperCommander->AllowSubRemoval(this);
  134. }
  135.  
  136.  
  137. // ---------------------------------------------------------------------------
  138. //        Ñ HandleKeyPress
  139. // ---------------------------------------------------------------------------
  140. //    DialogBox handles keyboard equivalents for hitting the Default and
  141. //    Cancel Buttons.
  142. //
  143. //        Default Button: Enter, Return
  144. //        Cancel Button:  Escape, Command-Period
  145.  
  146. Boolean
  147. LAboutBox::HandleKeyPress(
  148.     const EventRecord    &/*inKeyEvent*/)
  149. {
  150.     return mSuperCommander->AllowSubRemoval(this);
  151. }
  152.